/*
 * Copyright [vega-ai-sdk] [rightbrain.art]
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * According to vega feature, we modify some class，comment, field name, etc.
 */


package com.rightbrain.vegaai.tool.sdk.common;

import com.rightbrain.vegaai.tool.sdk.common.Resource;
import org.springframework.http.HttpStatus;
public enum ResourceCode {

    //资源响应编码http状态码(3位)+code(5位)
    //2XX000XX
    OK(Resource.resource("20000", "成功", HttpStatus.OK)),
    CREATED(Resource.resource("20000", "资源已创建", HttpStatus.CREATED)),

    //4XX000XX
    BAD_REQUEST(Resource.resource("00000", "资源访问错误", HttpStatus.BAD_REQUEST)),
    BAD_REQUEST_ARGS(Resource.resource("00001", "参数校验失败或参数缺失", HttpStatus.BAD_REQUEST)),
    BAD_REQUEST_LANGUAGE(Resource.resource("00002", "语义或语法无法正确解析", HttpStatus.BAD_REQUEST)),
    UNAUTHORIZED(Resource.resource("40100", "资源未经授权", HttpStatus.UNAUTHORIZED)),
    FORBIDDEN(Resource.resource("40100", "资源访问受限", HttpStatus.FORBIDDEN)),
    GONE(Resource.resource("40000", "资源丢失", HttpStatus.GONE)),
    NOT_ACCEPTABLE(Resource.resource("40000", "资源请求不可授理", HttpStatus.NOT_ACCEPTABLE)),
    UNAVAILABLE_FOR_LEGAL_REASONS(Resource.resource("40000", "资源操作错误", HttpStatus.UNAVAILABLE_FOR_LEGAL_REASONS)),
    REQUEST_METHOD_NOT_ALLOWED(Resource.resource("40200", "不支持的请求方法", HttpStatus.METHOD_NOT_ALLOWED)),

    //5XX000XX
    CONFLICT(Resource.resource("50400", "资源唯一标识冲突或资源已存在", HttpStatus.CONFLICT)),
    DB_REQUEST_TIMEOUT(Resource.resource("50002", "数据库访问超时", HttpStatus.REQUEST_TIMEOUT)),
    TOO_MANY_REQUESTS(Resource.resource("50001", "资源请求太频繁", HttpStatus.TOO_MANY_REQUESTS)),
    INTERNAL_SERVER_ERROR(Resource.resource("50000", "系统异常，请稍后重试", HttpStatus.INTERNAL_SERVER_ERROR)),
    SERVICE_UNAVAILABLE(Resource.resource("50003", "资源无法获取", HttpStatus.SERVICE_UNAVAILABLE));

    private Resource<String, HttpStatus> resource;

    ResourceCode(Resource<String, HttpStatus> resource) {
        this.resource = resource;
    }

    public String code () {
        //return resource.getData().value() + resource.getCode();
        return  resource.getCode();
    }

    public String message() {
        return resource.getMessage();
    }

    public HttpStatus status() {
        return resource.getData();
    }
}